package com.xl.sqlSession;

import com.xl.config.XmlConfigBuilder;
import com.xl.pojo.Configuration;

import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream inputStream){
        //1、使用dom4j解析配置文件，将解析出来的内容封装到Configuration中
        XmlConfigBuilder xmlConfigBuilder = new XmlConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);
        System.out.println(configuration);
        //2.创建SqlSessionFactory对象 : 工厂类：生产sqlSession会话对象
        SqlSessionFactory sqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        return sqlSessionFactory;

    }
}
